<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Namespace: net</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Namespace: net</h1>

    




<section>

<header>
    
        <h2>net</h2>
        
    
</header>

<article>
    <div class="container-overview">
    
        
            <div class="description"><p>Provides basic networking functions,
like beef.net.request and beef.net.forgeRequest,
used by BeEF command modules and the Requester extension,
as well as beef.net.send which is used to return commands
to BeEF server-side components.</p>
<p>Also, it contains the core methods used by the XHR-polling
mechanism (flush, queue)</p></div>
        

        


<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="net.js.html">net.js</a>, <a href="net.js.html#line7">line 7</a>
    </li></ul></dd>
    

    

    

    
</dl>


        
    
    </div>

    

    

    

    

    

    
        <h3 class="subsection-title">Namespaces</h3>

        <dl>
            <dt><a href="beef.net.connection.html">connection</a></dt>
            <dd></dd>
        
            <dt><a href="beef.net.cors.html">cors</a></dt>
            <dd></dd>
        
            <dt><a href="beef.net.dns.html">dns</a></dt>
            <dd></dd>
        
            <dt><a href="beef.net.local.html">local</a></dt>
            <dd></dd>
        
            <dt><a href="beef.net.portscanner.html">portscanner</a></dt>
            <dd></dd>
        
            <dt><a href="beef.net.requester.html">requester</a></dt>
            <dd></dd>
        
            <dt><a href="beef.net.xssrays.html">xssrays</a></dt>
            <dd></dd>
        </dl>
    

    

    
        <h3 class="subsection-title">Methods</h3>

        
            

    

    
    <h4 class="name" id=".array_has_string_key"><span class="type-signature">(static) </span>array_has_string_key<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Detects if an array has a string key</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="net.js.html">net.js</a>, <a href="net.js.html#line507">line 507</a>
    </li></ul></dd>
    

    

    

    
</dl>




















        
            

    

    
    <h4 class="name" id=".browser_details"><span class="type-signature">(static) </span>browser_details<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Sends back browser details to framework, calling beef.browser.getDetails()</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="net.js.html">net.js</a>, <a href="net.js.html#line550">line 550</a>
    </li></ul></dd>
    

    

    

    
</dl>




















        
            

    

    
    <h4 class="name" id=".chunk"><span class="type-signature">(static) </span>chunk<span class="signature">(str, amount)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Split the input data into chunk lengths determined by the amount parameter.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>str</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last"><p>the input data</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>amount</code></td>
            

            <td class="type">
            
                
<span class="param-type">Integer</span>


            
            </td>

            

            

            <td class="description last"><p>chunk length</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="net.js.html">net.js</a>, <a href="net.js.html#line179">line 179</a>
    </li></ul></dd>
    

    

    

    
</dl>




















        
            

    

    
    <h4 class="name" id=".clean"><span class="type-signature">(static) </span>clean<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>this is a stub, as associative arrays are not parsed by JSON, all key / value pairs should use new Object() or {}
http://andrewdupont.net/2006/05/18/javascript-associative-arrays-considered-harmful/</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="net.js.html">net.js</a>, <a href="net.js.html#line496">line 496</a>
    </li></ul></dd>
    

    

    

    
</dl>




















        
            

    

    
    <h4 class="name" id=".command"><span class="type-signature">(static) </span>command<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Command object. This represents the data to be sent back to BeEF,
using the beef.net.send() method.</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="net.js.html">net.js</a>, <a href="net.js.html#line35">line 35</a>
    </li></ul></dd>
    

    

    

    
</dl>




















        
            

    

    
    <h4 class="name" id=".flush"><span class="type-signature">(static) </span>flush<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Flush all currently queued command results to the framework,
chopping the data in chunks ('chunk' method) which will be re-assembled
server-side by the network stack.
NOTE: currently 'flush' is used only with the default
XHR-polling mechanism. If WebSockets are used, the data is sent
back to BeEF straight away.</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="net.js.html">net.js</a>, <a href="net.js.html#line147">line 147</a>
    </li></ul></dd>
    

    

    

    
</dl>




















        
            

    

    
    <h4 class="name" id=".forge_request"><span class="type-signature">(static) </span>forge_request<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Similar to beef.net.request, except from a few things that are needed when dealing with forged requests:</p>
<ul>
<li>requestid: needed on the callback</li>
<li>allowCrossDomain: set cross-domain requests as allowed or blocked</li>
</ul>
<p>forge_request is used mainly by the Requester and Tunneling Proxy Extensions.
Example usage:
beef.net.forge_request(&quot;http&quot;, &quot;POST&quot;, &quot;172.20.40.50&quot;, 8080, &quot;/lulz&quot;,
true, null, { foo: &quot;bar&quot; }, 5, 'html', false, null, function(response) {
alert(response.response_body)})</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="net.js.html">net.js</a>, <a href="net.js.html#line321">line 321</a>
    </li></ul></dd>
    

    

    

    
</dl>




















        
            

    

    
    <h4 class="name" id=".is_valid_ip"><span class="type-signature">(static) </span>is_valid_ip<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Checks if the specified IP address is valid</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="net.js.html">net.js</a>, <a href="net.js.html#line530">line 530</a>
    </li></ul></dd>
    

    

    

    
</dl>




















        
            

    

    
    <h4 class="name" id=".is_valid_ip_range"><span class="type-signature">(static) </span>is_valid_ip_range<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Checks if the specified IP address range is valid</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="net.js.html">net.js</a>, <a href="net.js.html#line540">line 540</a>
    </li></ul></dd>
    

    

    

    
</dl>




















        
            

    

    
    <h4 class="name" id=".is_valid_port"><span class="type-signature">(static) </span>is_valid_port<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Checks if the specified port is valid</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="net.js.html">net.js</a>, <a href="net.js.html#line521">line 521</a>
    </li></ul></dd>
    

    

    

    
</dl>




















        
            

    

    
    <h4 class="name" id=".packet"><span class="type-signature">(static) </span>packet<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Packet object. A single chunk of data. X packets -&gt; 1 stream</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="net.js.html">net.js</a>, <a href="net.js.html#line46">line 46</a>
    </li></ul></dd>
    

    

    

    
</dl>




















        
            

    

    
    <h4 class="name" id=".push"><span class="type-signature">(static) </span>push<span class="signature">(stream)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Push the input stream back to the BeEF server-side components.
It uses beef.net.request to send back the data.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>stream</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last"><p>the stream object to be sent back.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="net.js.html">net.js</a>, <a href="net.js.html#line189">line 189</a>
    </li></ul></dd>
    

    

    

    
</dl>




















        
            

    

    
    <h4 class="name" id=".queue"><span class="type-signature">(static) </span>queue<span class="signature">(handler, cid, results, status, callback)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Queues the specified command results.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>handler</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last"><p>the server-side handler that will be called</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>cid</code></td>
            

            <td class="type">
            
                
<span class="param-type">Integer</span>


            
            </td>

            

            

            <td class="description last"><p>command id</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>results</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last"><p>the data to send</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>status</code></td>
            

            <td class="type">
            
                
<span class="param-type">Integer</span>


            
            </td>

            

            

            <td class="description last"><p>the result of the command execution (-1, 0 or 1 for 'error', 'unknown' or 'success')</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>callback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            

            

            <td class="description last"><p>the function to call after execution</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="net.js.html">net.js</a>, <a href="net.js.html#line91">line 91</a>
    </li></ul></dd>
    

    

    

    
</dl>




















        
            

    

    
    <h4 class="name" id=".request"><span class="type-signature">(static) </span>request<span class="signature">(scheme, method, domain, port, path, anchor, data, timeout, dataType, callback)</span><span class="type-signature"> &rarr; {Object}</span></h4>
    

    



<div class="description">
    <p>Performs http requests</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>scheme</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last"><p>HTTP or HTTPS</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>method</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last"><p>GET or POST</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>domain</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last"><p>bindshell.net, 192.168.3.4, etc</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>port</code></td>
            

            <td class="type">
            
                
<span class="param-type">Int</span>


            
            </td>

            

            

            <td class="description last"><p>80, 5900, etc</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>path</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last"><p>/path/to/resource</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>anchor</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last"><p>this is the value that comes after the # in the URL</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>data</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last"><p>This will be used as the query string for a GET or post data for a POST</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>timeout</code></td>
            

            <td class="type">
            
                
<span class="param-type">Int</span>


            
            </td>

            

            

            <td class="description last"><p>timeout the request after N seconds</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>dataType</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last"><p>specify the data return type expected (ie text/html/script)</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>callback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            

            

            <td class="description last"><p>call the callback function at the completion of the method</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="net.js.html">net.js</a>, <a href="net.js.html#line219">line 219</a>
    </li></ul></dd>
    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>this object contains the response details</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Object</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id=".response"><span class="type-signature">(static) </span>response<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Response Object - used in the beef.net.request callback
NOTE: as we are using async mode, the response object will be empty if returned.
Using sync mode, request obj fields will be populated.</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="net.js.html">net.js</a>, <a href="net.js.html#line72">line 72</a>
    </li></ul></dd>
    

    

    

    
</dl>




















        
            

    

    
    <h4 class="name" id=".send"><span class="type-signature">(static) </span>send<span class="signature">(handler, cid, results, exec_status, callback)</span><span class="type-signature"> &rarr; {Integer}</span></h4>
    

    



<div class="description">
    <p>Queues the current command results and flushes the queue straight away.
NOTE: Always send Browser Fingerprinting results
(beef.net.browser_details(); -&gt; /init handler) using normal XHR-polling,
even if WebSockets are enabled.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>handler</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last"><p>the server-side handler that will be called</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>cid</code></td>
            

            <td class="type">
            
                
<span class="param-type">Integer</span>


            
            </td>

            

            

            <td class="description last"><p>command id</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>results</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last"><p>the data to send</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>exec_status</code></td>
            

            <td class="type">
            
                
<span class="param-type">Integer</span>


            
            </td>

            

            

            <td class="description last"><p>the result of the command execution (-1, 0 or 1 for 'error', 'unknown' or 'success')</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>callback</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            

            

            <td class="description last"><p>the function to call after execution</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="net.js.html">net.js</a>, <a href="net.js.html#line115">line 115</a>
    </li></ul></dd>
    

    

    

    
</dl>















<h5>Returns:</h5>

        
<div class="param-desc">
    <p>the command module execution status (defaults to 0 - 'unknown' if status is null)</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Integer</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id=".stream"><span class="type-signature">(static) </span>stream<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>Stream object. Contains X packets, which are command result chunks.</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="net.js.html">net.js</a>, <a href="net.js.html#line54">line 54</a>
    </li></ul></dd>
    

    

    

    
</dl>




















        
    

    

    
</article>

</section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="beef.are.html">are</a></li><li><a href="beef.browser.html">browser</a></li><li><a href="beef.browser.cookie.html">cookie</a></li><li><a href="beef.browser.popup.html">popup</a></li><li><a href="beef.dom.html">dom</a></li><li><a href="beef.encode.base64.html">base64</a></li><li><a href="beef.encode.json.html">json</a></li><li><a href="beef.geolocation.html">geolocation</a></li><li><a href="beef.hardware.html">hardware</a></li><li><a href="beef.init.html">init</a></li><li><a href="beef.logger.html">logger</a></li><li><a href="beef.mitb.html">mitb</a></li><li><a href="beef.net.html">net</a></li><li><a href="beef.net.connection.html">connection</a></li><li><a href="beef.net.cors.html">cors</a></li><li><a href="beef.net.dns.html">dns</a></li><li><a href="beef.net.local.html">local</a></li><li><a href="beef.net.portscanner.html">portscanner</a></li><li><a href="beef.net.requester.html">requester</a></li><li><a href="beef.net.xssrays.html">xssrays</a></li><li><a href="beef.os.html">os</a></li><li><a href="beef.session.html">session</a></li><li><a href="beef.timeout.html">timeout</a></li><li><a href="beef.updater.html">updater</a></li><li><a href="beef.webrtc.html">webrtc</a></li><li><a href="beef.websocket.html">websocket</a></li><li><a href="BeefJS.html">BeefJS</a></li><li><a href="browser_jools.html">browser_jools</a></li><li><a href="platform.html">platform</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Thu Jan 02 2020 16:29:11 GMT+1000 (Australian Eastern Standard Time)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>